﻿Imports IETracker.Business.Entities
Imports IETracker.Business.Compents
Imports System.Collections.ObjectModel

' NOTE: You can use the "Rename" command on the context menu to change the class name "Service1" in both code and config file together.
Public Class IETrackerService
    Implements IIETrackerService

    Public Function GetTransactionList() As List(Of TransactionList) Implements IIETrackerService.GetTransactionList
        Try
            Dim cc As New TransactionListComponent

            Return cc.GenerateTransactionList("")
        Catch ex As Exception
            Throw New FaultException(Of ProcessExecutionFault)(New ProcessExecutionFault(), ex.Message)
        End Try
    End Function

    Public Function GetExpenseList(Optional endDate As Date = #12:00:00 AM#, Optional returnNumberOfTransactions As Integer = 0) As List(Of TransactionList) Implements IIETrackerService.GetExpenseList
        Try
            Dim cc As New TransactionListComponent

            Return cc.GenerateTransactionList("expense", endDate, returnNumberOfTransactions)
        Catch ex As Exception
            Throw New FaultException(Of ProcessExecutionFault)(New ProcessExecutionFault(), ex.Message)
        End Try
    End Function


    Public Function GetIncomeList(Optional endDate As Date = #12:00:00 AM#, Optional returnNumberOfTransactions As Integer = 0) As List(Of TransactionList) Implements IIETrackerService.GetIncomeList
        Try
            Dim cc As New TransactionListComponent

            Return cc.GenerateTransactionList("income", endDate, returnNumberOfTransactions)
        Catch ex As Exception
            Throw New FaultException(Of ProcessExecutionFault)(New ProcessExecutionFault(), ex.Message)
        End Try
    End Function

    Public Function GetTransactionDescriptions(_transactionType As String) As List(Of String) Implements IIETrackerService.GetTransactionDescriptions
        Try
            Dim cc As New TransactionListComponent

            Return cc.GetTransactionTypes(_transactionType)
        Catch ex As Exception
            Throw New FaultException(Of ProcessExecutionFault)(New ProcessExecutionFault(), ex.Message)
        End Try
    End Function

    Public Function ReadAllTransaction() As List(Of Transaction) Implements IIETrackerService.ReadAllTransaction
        Try
            Dim cc As New TransactionListComponent

            Return cc.ReadAllTransactions
        Catch ex As Exception
            Throw New FaultException(Of ProcessExecutionFault)(New ProcessExecutionFault(), ex.Message)
        End Try
    End Function

#Region "Transaction"
    Public Function CreateTransaction(_transaction As TransactionList) As TransactionList Implements IIETrackerService.CreateTransaction
        Try
            Dim cc As New TransactionListComponent

            Return cc.CreateTransaction(_transaction)
        Catch ex As Exception
            Throw New FaultException(Of ProcessExecutionFault)(New ProcessExecutionFault(), ex.Message)
        End Try
    End Function
#End Region
   
End Class
